<?php
include_once ('head.php');

?>
<div class="container" style="max-width: 1024px;">
	<div class="layui-card">
		<div class="layui-card-header">记录列表</div>
		<div class="layui-card-body">
			<div style="text-align: left;">
				<div class="layui-form layui-form-pane">
					<label class="layui-form-label">搜索</label>
					<div class="layui-input-block">
						<input type="text" id="content" autocomplete="off" placeholder="请输入关键字" value="<?=$_POST['content']?>" class="layui-input" style="padding-right: 68px;">
						<button style="position: absolute;top: 0;right: 1px; cursor: pointer;" type="button" class="layui-btn" onclick="search()">搜索</button>
					</div>
				</div>
				
				<table id="list" class="layui-table"></table>

			</div>
		</div>
	</div>
</div>
	<!-- script src="../layui/layui.js"></script -->
	<script src="../layui/layui.all.js"></script>
	<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
	<!--您的Layui代码start-->
	<script type="text/javascript">
		layui.use('table',function() {
			var table = layui.table;
			table.render({
				elem: '#list',
				height: 500,
				url: 'Ajax.php?my=userlist', //数据接口
				page: true, //开启分页
				cols: [[ //表头
				{
					field: 'uid',
					title: 'UID',
					width: 80
				},{
					field: 'user',
					title: '用户名',
					width: 100
				},{
					field: 'qq',
					title: 'QQ账号',
					width: 150
				},{
					field: 'regtime',
					title: '注册日期',
				},{
					field: 'lasttime',
					title: '最后登录/IP',
					width: 250
				},{
					field: 'caozuo',
					title: '操作',
				}]]
			});
		});

		function search(){
			var content = $('#content').val();
			if(content==''){
				// layer.msg('请输入关键字',{icon: 5});
				layui.table.reload('list', {
					url: 'Ajax.php?my=userlist'
				});
			}else{
				layui.table.reload('list', {
					url: 'Ajax.php?my=userlist&search=' + content
				});
			}
		}
		
		function deluser(uid){
			if(uid==''){
				layer.msg('参数错误',{icon: 5});
			}else{
				layer.confirm('确定要删除此账号吗？', {btn: ['确定','取消']}, function(){
					var index = layer.load(1, {shade: [0.6,'#000']}); //0.1透明度的白色背景
					$.ajax({
						type: "post",   
						url:  "Ajax.php", 
						data: "my=deluser&uid="+uid,
						dataType: "json",
						success: function (res) {
							layer.close(index);
							if(res.code==1){
								layer.msg(res.msg,{icon: 6});
								layui.table.reload('list', {
									url: 'Ajax.php?my=userlist'
								});
							}else if(res.code==0){
								layer.msg(res.msg,{icon: 5});
							}
						},
						error: function (res) {
							layer.msg('请求失败',{icon: 5});
							layer.close(index);
						}   
					});
				});
			}
		}
	</script>
</body>
</html>
